package modelo.hibernate.config;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;


public class Sesion {
			
			 private static final SessionFactory sessionFactory;
			    static {
			       
			      AnnotationConfiguration cfg2 = new AnnotationConfiguration();
			       
			        try { 
			           
			        	sessionFactory = cfg2.configure("hibernate.cfg.xml").buildSessionFactory();
			        	//	sessionFactory = cfg2.configure(new File("hibernate.cfg.xml")).buildSessionFactory();
			          
			        } catch (Throwable ex) {
			            ex.printStackTrace();
			            throw new ExceptionInInitializerError(ex);
			        }

			    }

			    public static Session openSession() throws HibernateException {
			        return sessionFactory.openSession();
			    }

		}

